﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;

namespace QLKSOrange
{
    public partial class DangNhapSQL : Form
    {
        public DangNhapSQL()
        {
            InitializeComponent();
        }

        private void DangNhapSQL_Load(object sender, EventArgs e)
        {
            radioButtonLocal.Checked = true;
            DoiTrangThai(false);
        }      

        private void label2_Click(object sender, EventArgs e)
        {

        }
        private void DoiTrangThai(Boolean f)
        {
            txtServer.Enabled = f;
            txtUser.Enabled = f;
            txtPass.Enabled = f;
        }
        private void radioButtonLocal_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButtonLocal.Checked == true)
            {
                DoiTrangThai(false);
                txtServer.Text = "";
                txtUser.Text = "";
                txtPass.Text = "";
            }
        }

        private void radioButtonServer_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButtonServer.Checked == true)
            {
                DoiTrangThai(true);
                txtServer.Focus();
            }
        }

        //private void btnThem_Click(object sender, EventArgs e)
        //{
        //    //if(txtDatabase.Text.ToString().Trim().Length<=0)
        //    //{
        //    //    MessageBox.Show("Xác định DataBase", "Thong Bao", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        //    //    txtDatabase.Focus();
        //    //    return;

        //    //}
        //    //string path = Application.StartupPath.ToString();
        //    //FileInfo file = new FileInfo(path + "\\TrungTamTinHoc.ini");
        //    //if (file.Exists)
        //    //{
        //    //file.Attributes = FileAttributes.Normal;
        //    //file.Delete();
        //    //}
        //    //FileStream fi = file.Create();
        //    //file.Attributes = FileAttributes.ReadOnly;
        //    //StreamWriter wter = new StreamWriter(fi, System.Text.Encoding.UTF8);
        //    //string str;
        //    ////Get connnectionstring
        //    //if (radioButtonLocal.Checked == true)
        //    //    str = "Data Source=(local);Initial Catalog=" + txtDatabase.Text.ToString() + ";Integrated Security=SSPI";
        //    //else
        //    //    str = "Data Source=" + txtServer.Text.ToString() + ";Initial Catalog=" + txtDatabase.Text.ToString() + ";User Id=" + txtUser.Text.ToString() + ";Password=" + txtPass.Text.ToString() + ";"; 
        //    //wter.WriteLine(str);
        //    //wter.Close();
        //    //fi.Close();


        //    //AbstractBUS busAbstract = new AbstractBUS();
        //    //if (!busAbstract.ThietDatChuoiKetNoi())
        //    //{
        //    //    MessageBox.Show("Không kết nối được với cơ sở dữ liệu !", "Thong bao", MessageBoxButtons.OK);
        //    //}
        //    //else
        //    //    this.Close();

        //}

        private void btnKetNoi_Click(object sender, EventArgs e)
        {

        }
    }
}